package com.zhugang.week01;

/**
 * @program algorithms
 * @description: divingBoard
 * @author: chanzhugang
 * @create: 2022/04/06 08:22
 */
public class DivingBoard {

    public static void main(String[] args) {
        DivingBoard board = new DivingBoard();
        int shorter = 3;
        int longer = 6;
        int k = 3;
        int[] result = board.divingBoard(shorter, longer, k);
        for (int i : result) {
            System.out.println(i);
        }
    }

    /**
     * 跳水板 ： 短的shorter， 长的longer, 共k块， 求功能组成多少不同长度，从小到大排序
     */
    public int[] divingBoard(int shorter, int longer, int k) {
        if (k == 0) return new int[0];
        if (shorter == longer) return new int[]{k * shorter};
        int[] result = new int[k + 1];
        for (int i = 0; i <= k; i++) {
            result[i] = longer * i + shorter * (k - i);
        }
        return result;
    }


}